package com.zr.sms.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import com.zr.sms.model.Goods;
import com.zr.sms.service.SelectService;
import com.zr.sms.serviceimpl.SelectServiceImpl;

public class SerchGoodsServlet extends HttpServlet{
	SelectService selectservice=new SelectServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
	  doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		 resp.setCharacterEncoding("utf-8");
	     int gid=Integer.parseInt(req.getParameter("gid"));
	     Goods good=selectservice.getGoodsByGid(gid);
	     JSONObject goods=JSONObject.fromObject(good);
	     PrintWriter out=resp.getWriter();
	     out.write(goods.toString());
	    
	}

}
